import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_base_widget/main.dart';

class Info{

  int right;
  int left;
  int bottom;
  int top;
  Info(this.right, this.left, this.bottom, this.top);
  //简单计算
  int get area => (right - left) * (bottom - top);
  //简单的转换
  String capitalize(String name) =>
      '${name[0].toUpperCase()}${name.substring(1)}';

}

class UserBean{
  ///不为null
  int userType = 1;
  ///可能为null
  String ? userName;

  UserBean.fromMap(Map map){
    //为null时 要设置默认值
    userType = map["userType"]??1;
    userName = map["userName"];
  }
}

///建议这样
class PointBean {
  int x, y;
  PointBean(this.x, this.y);
}
void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    int a = 22;
    int b = 33;
    //输出一下类型 List<int>
    debugPrint("两个值 相差${a - b}");

    String name = "张三";
    //不建议这样写
    debugPrint("用户的姓名是${name}");

    //建议这样写
    debugPrint("用户的姓名是$name");
  });

  //不建议这样写
  //参数a 非必填 默认 10
  void add({int a: 10}) {
    debugPrint("a的值是 $a");
  }

  //建议使用 = 号
  //参数a 非必填 默认 10
  void add2({int a = 10}) {
    debugPrint("a的值是 $a");
  }
  Future<int> downCacue(int a,int b) async{
    //这里是耗时任务
    return Future.value(a+b);
  }

  void testDown() async{
    //异步计算 获取结果
    int result1 = await downCacue(1,2);
  }

}
